"""modify ai_api

Revision ID: f131e579aca8
Revises: 26d5a3306732
Create Date: 2025-04-08 19:51:26.566728

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql

# revision identifiers, used by Alembic.
revision: str = 'f131e579aca8'
down_revision: Union[str, None] = '26d5a3306732'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('ai_agents', 'system_prompt',
               existing_type=mysql.LONGTEXT(collation='utf8mb4_general_ci'),
               type_=sa.TEXT(length=16777216),
               existing_nullable=True)
    op.add_column('ai_api', sa.Column('type', sa.String(length=16), server_default=sa.text("'openai'"), nullable=False, comment='类型'))
    op.add_column('ai_api', sa.Column('is_system', sa.String(length=16), server_default=sa.text("'NO'"), nullable=False, comment='状态'))
    op.add_column('ai_model', sa.Column('model_group', sa.String(length=255), nullable=False, comment='模型分组'))
    op.alter_column('funcall_log', 'log_text',
               existing_type=mysql.LONGTEXT(collation='utf8mb4_general_ci'),
               type_=sa.TEXT(length=16777216),
               existing_comment='日志信息',
               existing_nullable=True)
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('funcall_log', 'log_text',
               existing_type=sa.TEXT(length=16777216),
               type_=mysql.LONGTEXT(collation='utf8mb4_general_ci'),
               existing_comment='日志信息',
               existing_nullable=True)
    op.drop_column('ai_model', 'model_group')
    op.drop_column('ai_api', 'is_system')
    op.drop_column('ai_api', 'type')
    op.alter_column('ai_agents', 'system_prompt',
               existing_type=sa.TEXT(length=16777216),
               type_=mysql.LONGTEXT(collation='utf8mb4_general_ci'),
               existing_nullable=True)
    # ### end Alembic commands ###
